package com.triz.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.triz.common.annotation.Log;
import com.triz.common.core.controller.BaseController;
import com.triz.common.core.domain.AjaxResult;
import com.triz.common.enums.BusinessType;
import com.triz.business.domain.NationalPolicy;
import com.triz.business.service.INationalPolicyService;
import com.triz.common.utils.poi.ExcelUtil;
import com.triz.common.core.page.TableDataInfo;

/**
 * 国家政策信息Controller
 * 
 * @author hlk
 * @date 2025-11-11
 */
@RestController
@RequestMapping("/business/nationalPolicy")
public class NationalPolicyController extends BaseController
{
    @Autowired
    private INationalPolicyService nationalPolicyService;

    /**
     * 查询国家政策信息列表
     */
//    @PreAuthorize("@ss.hasPermi('business:nationalPolicy:list')")
    @GetMapping("/list")
    public TableDataInfo list(NationalPolicy nationalPolicy)
    {
        startPage();
        List<NationalPolicy> list = nationalPolicyService.selectNationalPolicyList(nationalPolicy);
        return getDataTable(list);
    }

    /**
     * 导出国家政策信息列表
     */
//    @PreAuthorize("@ss.hasPermi('business:nationalPolicy:export')")
    @Log(title = "国家政策信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NationalPolicy nationalPolicy)
    {
        List<NationalPolicy> list = nationalPolicyService.selectNationalPolicyList(nationalPolicy);
        ExcelUtil<NationalPolicy> util = new ExcelUtil<NationalPolicy>(NationalPolicy.class);
        util.exportExcel(response, list, "国家政策信息数据");
    }

    /**
     * 获取国家政策信息详细信息
     */
//    @PreAuthorize("@ss.hasPermi('business:nationalPolicy:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(nationalPolicyService.selectNationalPolicyById(id));
    }

    /**
     * 新增国家政策信息
     */
//    @PreAuthorize("@ss.hasPermi('business:nationalPolicy:add')")
    @Log(title = "国家政策信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NationalPolicy nationalPolicy)
    {
        nationalPolicy.setCreateBy(getUsername());
        return toAjax(nationalPolicyService.insertNationalPolicy(nationalPolicy));
    }

    /**
     * 修改国家政策信息
     */
//    @PreAuthorize("@ss.hasPermi('business:nationalPolicy:edit')")
    @Log(title = "国家政策信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NationalPolicy nationalPolicy)
    {
        nationalPolicy.setUpdateBy(getUsername());
        return toAjax(nationalPolicyService.updateNationalPolicy(nationalPolicy));
    }

    /**
     * 删除国家政策信息
     */
//    @PreAuthorize("@ss.hasPermi('business:nationalPolicy:remove')")
    @Log(title = "国家政策信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(nationalPolicyService.deleteNationalPolicyByIds(ids));
    }



}
